<template>
	<view class="School_personal_Center">
		<cu-custom bgColor="bg-blue" :isBack="true">
			<block slot="content">高校实训平台</block>
		</cu-custom>
		<view class="head_id" @tap="write">
			<view class="head_id_head">
				<view class="head_portrait">
					<view class="head_portrait_img">
						<image :src="user_info.avatar"></image>
					</view>
				</view>
				<view class="school">
					<view class="school_name">{{user_info.real_name||user_info.nickname}}</view>
					<view class="school_id">ID:{{user_info.user_id}}</view>
				</view>
				<view class="school_more iconfont icon-you1"></view>
			</view>
		</view>

		<view class="school_nav">
			<view class="schol_nav_post" @tap="toclassgroup">
				<image src="../../static/ClassManagement.png"></image>
				<view class="schol_post_li">我的班级</view>
			</view>
			<view class="schol_nav_post" @tap="tofirmcooper">
				<image src="../../static/Enterprise.png"></image>
				<view class="schol_post_li">我的企业</view>
			</view>
			<view class="schol_nav_post" @tap="toresume">
				<image src="../../static/Resume.png"></image>
				<view class="schol_post_li">电子简历</view>
			</view>
			<view class="schol_nav_post" @tap="tomessage">
				<view class="schol_post_number" v-if="msgnums.count>0">{{msgnums.count}}</view>
				<image src="../../static/news.png"></image>
				<view class="schol_post_li">消息通知</view>
			</view>
		</view>

		<view class="School_list" v-if="!student_info.company_id">
			<view class="school_btto">
				<text class="schol_li">企业列表</text>
				<text style="float: right; font-size: 20rpx; color: #999999; margin-right: 30rpx; margin-top: 8rpx;"
					@tap="more">查看更多</text>
				<!-- <block v-for="out of 5" :key="'out_' + out"> -->
				<view class="ScholLiLoop" v-for="(item,index) in list" :key="index" :data-comany_id="item.comany_id"
					@tap="EnterpriseId(item.company_id)">
					<view class="schol_hoto">
						<view class="School_information_li">
							<!-- <image :src="item.logo" mode="aspectFill"></image> -->
							<block>
								<image :src="item.logo" v-if="item.logo" mode="aspectFill"></image>
								<view v-else
									style="width: 110rpx; height: 110rpx; border-radius: 10rpx; background-color: #2C405A; 
									color: #FFFFFF; font-size: 50rpx;
									text-align: center; padding: 25rpx; display: inline-block;">
									{{item.company_name[0]}}
								</view>
							</block>
						</view>
						<view class="form_ul">
							<view class="school_uid">{{item.company_name}}</view>
							<view class="school_badge">
								<view style="padding-left: 10rpx;" v-for="(tags_item,tags_index) in item.tags"
									:key="tags_index">{{tags_item,tags}}
								</view>
							</view>
						</view>
						<view class="school_information  iconfont icon-you1"></view>
					</view>
				</view>
				<!-- </block> -->
			</view>
		</view>

		<view class="School_list" v-if="student_info.company_id">
			<view class="school_btto">
				<view class="schol_li">企业工作台</view>
			</view>

			<view class="enterprise_Console">
				<view class="Sign_in" @tap="tosignin">
					<view class="Sign_in_bak" style="background-color: #1384ff; ">
						<view class="Sign_in_img iconfont icon-qiandao1"
							style="padding-top: 15rpx; font-size: 65rpx; padding-top: 18rpx;"></view>
					</view>
					<view class="Sign_in_li">签到打卡</view>
				</view>
				<view class="Sign_in" @tap="toquanzi">
					<view class="Sign_in_bak" style="background-color: #1dd1bf;">
						<view class="Sign_in_img iconfont icon-chengguo"
							style="padding-top: 15rpx; font-size:70rpx; padding-top: 18rpx;"></view>
					</view>
					<view class="Sign_in_li">实训成果</view>
				</view>
				<view class="Sign_in" @tap="toresume">
					<view class="Sign_in_bak" style="background-color: #faab1d;">
						<view class="Sign_in_img iconfont icon-jianli1"
							style="margin-left: -14px; font-size: 90rpx; padding-top: 5rpx;"></view>
					</view>
					<view class="Sign_in_li">我的简历</view>
				</view>
				<view class="Sign_in" @tap="tomessage">
					<view class="Sign_in_bak" style="background-color: #fe4c5f;">
						<view class="Sign_in_img iconfont icon-xiaoxitongzhi"
							style="padding-top: 20rpx; font-size: 58rpx; padding-top: 20rpx;"></view>
					</view>
					<view class="Sign_in_li">消息通知</view>
				</view>
				<view class="Sign_in" @tap="more">
					<view class="Sign_in_bak" style="background-color: #6c6de5;">
						<view class="Sign_in_img iconfont icon-qiye3"
							style="padding-top: 18rpx; font-size: 55rpx; padding-top: 20rpx;	"></view>
					</view>
					<view class="Sign_in_li">更多企业</view>
				</view>
			</view>

		</view>
	</view>

</template>

<script>
	const {
		appLogin,
		httpGet,
		httpPost,
		msg,
		timeToStr
	} = require("@/utils/common.js")
	export default {
		data() {
			return {
				page: 1,
				list: [],
				logo: '',
				count: '',
				msgnums: [],
				real_name: '',
				user_info: {},
				page_size: 20,
				tourist: true,
				student: true,
				student_info: {},
				enterprise_li: [],
				btnText: 'identity',
				timeToStr: timeToStr,
			}
		},
		onShow() {
			appLogin((user_info) => {
				console.log(user_info) // 获取学生信息
				// if(user_info.identity == 'student'){
				// 	console.log('是学生')
				// 	this.tourist = !this.tourist;
				// }
				// else{
				// 	console.log('不是学生')
				// 	this.btnText = tourist
				// }
				this.user_info = user_info
				// this.identity = identity
				this.gatpage()
				this.getstudentinfo()
				this.getnoticecount()
			})

		},
		// onShow() {
		// 	this.getstudentinfo()
		// },
		methods: {
			getnoticecount() {
				httpGet({
					url: '/api/student/notice_count',
				}).then((res) => {
					console.log(res)
					this.msgnums = res.result['10']
				})
			},
			// 企业列表
			write() {
				uni.navigateTo({
					url: "/pages/student/myProfile"
				})
			},
			toresume() {
				uni.navigateTo({
					url: "/pages/student/resume"
				})
			},
			tosignin() {
				uni.navigateTo({
					url: "/pages/student/attendance"
				})
			},
			tomessage() {
				uni.navigateTo({
					url: "/pages/student/message"
				})
			},
			toclassgroup() {
				uni.navigateTo({
					url: "/pages/student/myclassgroup?class_id=" + this.student_info.class_id
				})
			},
			tofirmcooper() {
				if (!this.student_info.company_id) {
					msg('你未加入企业哦','none')
				} else {
					uni.navigateTo({
						url: "/pages/student/firmcooperation?company_id=" + this.student_info
							.company_id
					})

				}
			},

			EnterpriseId(company_id) {
				console.log(company_id)
				uni.navigateTo({
					url: "firmcooperation?company_id=" + company_id
				})
			},
			// 学校详情
			toquanzi() {
				uni.navigateTo({
					url: "/pages/student/practicecircled"
				})
			},
			more() {
				uni.navigateTo({
					url: "/pages/student/morecompany?company_id=" + this.student_info.company_id
				})
			},
			getstudentinfo() {
				httpGet({
					url: '/api/student/info'
				}).then((res) => {
					this.student_info = res.result
					this.user_info.real_name = res.result.real_name
					console.log(res)
				})
			},

			gatpage() {
				httpGet({
					url: '/api/student/cooperate_company_list',
					data: {
						page: this.page,
						page_size: this.page_size,

					}
				}).then((res) => {
					console.log(res)
					this.list = res.result.list.splice(0, 5);
				})
			},

		}
	}
</script>

<style>
	.School_personal_Center {
		width: 100vw;
		height: 100vh;
		background-color: #f7f7f7;
	}

	.head_id {
		width: 100%;
		height: 330rpx;
		margin-bottom: 120rpx;
		background-color: #3b73f6;
	}

	.head_id_head {
		display: flex;
		padding-top: 30rpx;
	}

	.head_portrait {
		width: 19%;
		display: flex;
		margin-left: 20rpx;
	}

	.head_portrait_img {
		width: 120rpx;
		border: solid;
		height: 120rpx;
		border-radius: 50%;
		border-width: 1px;
		border-color: #FFFFFF;
	}

	.head_portrait_img image {
		border-radius: 50%;
		width: 120rpx;
		height: 120rpx;
	}

	.school {
		margin-top: 20rpx;
		width: 59%;
		color: #FFFFFF;
		text-align: left;
	}

	.school_name {
		font-family: ;
		font-size: 0.85em;
		letter-spacing: 2rpx;
	}

	.school_id {
		opacity: 0.5;
		font-size: 27rpx;
		margin-top: 15rpx;
	}

	.school_more {
		width: 13%;
		color: #FFFFFF;
		margin-left: 20rpx;
		margin-top: 40rpx;
		text-align: right;
	}

	.school_nav {
		width: 95%;
		clear: both;
		display: flex;
		height: 230rpx;
		margin-top: -250rpx;
		margin-left: 20rpx;
		border-radius: 25rpx;
		margin-bottom: 20rpx;
		background-color: #FFFFFF;
	}

	.school_nav image {
		margin-top: 45rpx;
		width: 57rpx;
		height: 57rpx;
	}

	.schol_nav_post {
		width: 25%;
		position: relative;
		text-align: center;
	}

	.schol_post_li {
		margin-top: 15rpx;
		font-size: 25rpx;
		color: #808080;
	}

	.schol_hoto {
		clear: right;
		display: flex;
		margin-left: 20rpx;
		margin-right: 20rpx;
		padding: 20rpx 0rpx 20rpx 0rpx;
		border-bottom: solid 0.01em #eeeeee;
	}

	.School_information_li {}

	.School_information_li image {
		border-radius: 100%;
		width: 110rpx;
		height: 110rpx;
	}

	.form_ul {
		width: 520rpx;
		margin-left: 10rpx;
		margin-top: 10rpx;
	}

	.school_badge {
		color: #999999;
		margin-top: 10rpx;
		font-size: 0.8em;
		display: flex;
	}

	.school_information {
		display: flex;
		font-size: 45rpx;
		margin-top: 30rpx;
	}

	.schol_post_number {
		top: -9rpx;
		right: 2.5px;
		width: 33rpx;
		height: 33rpx;
		margin: 40rpx;
		position: absolute;
		font-size: 13px;
		color: #FFFFFF;
		border-radius: 50%;
		background-color: #ff4444;
	}

	.School_list {
		width: 95%;
		height: 960rpx;
		margin: 0 auto;
		border-radius: 25rpx;
		background-color: #FFFFFF;
	}

	.school_btto {
		width: 100%;
		padding: 20rpx 0rpx 20rpx 0rpx;
	}

	.schol_li {
		margin-left: 40rpx;
		font-size: 13px;
		font-weight: bold;
	}

	.enterprise_Console {
		display: flex;
		flex-wrap: wrap;
	}

	.Sign_in {
		width: 25%;
		/* 两种布局方式 */
		/* display: inline-block; */
		height: 178rpx;
	}

	.Sign_in_bak {
		margin: 0 auto;
		margin-top: 20rpx;
		width: 100rpx;
		height: 100rpx;
		border-radius: 25%;
	}

	.Sign_in_img {
		color: #FFFFFF;
		text-align: center;
	}

	.Sign_in_li {
		padding-top: 10rpx;
		font-size: 12px;
		text-align: center;
	}
</style>
